<?php
//    require_once('class.BasicAnalyzer.php');
    /**
    * 用于提取youku网站的视频
    *
    */
    class YoukuAnalyzer extends BasicAnalyzer implements Analyzer
    {
        public $features = array("url" => "/http:\/\/v.youku.com\/v_show\/.*/i");

        public function analyze($content, $url)
        {
            $ret = array();
            //==================================
            //
            $arr = array();
            preg_match("/sendVideoLink\([^,]*,'([^']*)'/", $content, $arr);
            $vid  = $arr[1];
            $sid  = time() . "" . rand(0, 998) . "". (1000 + rand(0,1000))  ;
            $geturl = "http://f.youku.com/player/getFlvPath/sid/{$sid}_00/st/flv/fileid/{$vid}";
            $vurl = $geturl;
            $referer = $url;
            preg_match("/<meta name=\"title\" content=\"([^\"]*)\">/", $content, $arr);
            $title =$arr[1];
            preg_match("/<meta name=\"description\" content=\"([^\"]*)\">/", $content, $arr);
            $descr =$arr[1];
            preg_match("/<meta name=\"keywords\" content=\"([^\"]*)\">/", $content, $arr);
            $keyw =$arr[1];
            $arr = explode(",", $keyw);
            $tags = $arr[0];
            $tags = explode(" ",$tags);
            $tags[] = 'sr_youku';
            $category =$arr[1];
            $ext ="";
            $pub_date ="";
            preg_match("/class='userName'>([^\"]*)<\/a>/", $content, $arr);
            $author =$arr[1];
            //===================================
            $rv = array(
                array(
                    "url" => $vurl, 
                    "title" => $title,
                    "descr" => $descr,
                    "referer" => $referer,
                    "tags" => $tags, 
                    "category" => $category,
                    "ext" => $ext,
                    "pub_date" => $pub_date,
                    "author" => $author
                    )
                );

            
            //===================================

            return $rv;
        }
    }

?>
